import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class t816 {
    //816. 模糊坐标 中等
    //["(1,23)","(1.2,3)","(12,3)","(1,2.3)"]
    //["(1, 2.3)","(1, 23)","(1.2, 3)","(12, 3)"]
    public static void main(String[] args) {
        String s = "(12345678)";
        ambiguousCoordinates(s);
        //ambiguousCoordinates(s).forEach(str -> System.out.println(str));
    }
    //优化  先分割成两个 然后判断小数点合法即可
    public static List<String> ambiguousCoordinates(String s) {
        List<String> list = new ArrayList<>();
        String sr = s.substring(1, s.length() - 1);
       // String[] arr = s.substring(1, s.length() - 1).split("");
        String str = "";
        String ss1 = "";
        String ss2 = "";
        String sss1 = "";
        String sss2 = "";
        for (int i = 1; i < sr.length(); i++) {
            /*********无点************/
            ss1 = sr.substring(0, i);
            ss2 = sr.substring(i, sr.length());
            if (check(ss1.split("")) && check(ss2.split(""))) {
                list.add("(" + ss1 + ", " + ss2 + ")");
            }

            if (ss1.length() >= 2 && ss2.length() >= 2) {

               // System.out.println(ss1);System.out.println("分解如下:");
                //String[] arr1 = ss1.split("");
                //String[] arr2 = ss2.split("");
                for (int k = 1; k < ss1.length(); k++) {
                    sss1 = ss1.substring(0,k)+"."+ss1.substring(k,ss1.length());
                    //System.out.println(sss1);
//                    for (int j = 0; j < k; j++) {
//                        sss1 += arr1[j];
//                    }
//                    sss1 += ".";
//                    for (int j = k; j < arr1.length; j++) {
//                        sss1 += arr1[j];
//                    }
                    for (int p = 1; p < ss2.length(); p++) {
                        sss2 = ss2.substring(0,p)+"."+ss2.substring(p,ss2.length());
//                        for (int j = 0; j < p; j++) {
//                            sss2 += arr2[j];
//                        }
//                        sss2 += ".";
//                        for (int j = p; j < arr2.length; j++) {
//                            sss2 += arr2[j];
//                        }
                        if (check(sss1.split("")) && check(sss2.split(""))) {
                            list.add("(" + sss1 + ", " + sss2 + ")");
                        }
                    }
                }
            }
            /****************有一个点****************/
            str = sr.substring(0,i)+"."+sr.substring(i,sr.length());
            System.out.println(str);
//            for (int j = 0; j < i; j++) {
//                str += arr[j];
//            }
//            str += ".";
//            for (int j = i; j < arr.length; j++) {
//                str += arr[j];
//            }
            String s1 = "";
            String s2 = "";
            for (int j = 0; j < str.length() - 1; j++) {
                s1 = str.substring(0, j + 1);
                s2 = str.substring(j + 1, str.length());
                if (check(s1.split("")) && check(s2.split(""))) {
                    list.add("(" + s1 + ", " + s2 + ")");
                }
            }
            str = "";
        }
        return list;
    }

    public static boolean check(String arr[]) {
        //排除开头为. 结尾为. 结尾为.0 开头为00  结尾为00 开头为0X
        //System.out.println(Arrays.toString(arr));
        if (arr.length >= 1 && arr[0].equals(".") || arr[arr.length - 1].equals(".")
                || (arr.length >= 2 && arr[arr.length - 2].equals(".") && arr[arr.length - 1].equals("0"))
                || (arr.length >= 2 && arr[0].equals("0") && arr[1].charAt(0) >= '0')

        ) {
            return false;
        }else{
            for(int i = 0;i<arr.length;i++){
                if(arr[i].equals(".") && arr[arr.length-1].equals("0")){
                    return false;
                }
            }
        }
        return true;
    }

}
